package FamilyTherapy;

public class MagicToolCard extends Card
{
	//they are static, because MTCard is special case, we don't need to "new" every time
	public static final String[] magicCard = {"C1_Decision Maker", 
											"C2_No Deduction", 
											"C3_Show Feeling", 
											"C4_Bound Back", 
											"C5_Assign Descsion Maker"};
	
	private static final String[] magicDescription ={"C1_Player can be decision maker of current event",
											"C2_Player can defense himself wihtout being deducted SE point",
											"C3_Player can express his feeling to decsion maker to avoid being deducted",
											"C4_Player can bound back the deduction punishment to decision maker",
											"C5_Player can assign another player to be decision maker"};
	
	private int effectNo;
		
	public MagicToolCard() {		
	}
		
	public int switchMT(int num, EventCard currentEvent, int choice, int currentPlayerNo, Player p[], int decisionMakerNo) 
	{
		switch(num) 
		{
			case 0:
				return beDescisionMaker(currentPlayerNo, p);
			case 1:
				return noDeduction();
			case 2:
				return noDeuctionAsFeeling();
			case 3:
				return noDeductionAsRebound(currentEvent, choice, decisionMakerNo, p);
			case 4:
				return assignDescisionMaker(currentEvent, currentPlayerNo, p);
			default:
				return choice;	
		}		
	}
		
	public int beDescisionMaker(int currentPlayerNo, Player p[]) 
	{
		int choice=100;
		
		GCWindow.outputStr("Now, you use this card to be DecisionMaker!\n");
		choice=GCWindow.inputInt(Main.decisionMin, Main.decisionMax,
					"The decision maker is: " + p[currentPlayerNo].getName()
					+ ".\nPlease input your decision (1-4): \n");

		return choice;
	}
		
	public int noDeduction() 
	{
		GCWindow.outputStr("Now, you use noDeduction card so that no SE point will not be deducted.\n");
		return -1;
	}
	public int noDeuctionAsFeeling() 
	{
		GCWindow.outputStr("Now, you use noDeuctionAsFeeling card.\n" +
				"Please show your feeling so that no SE point will not be deducted.\n");
		return -1;
	}
	public int noDeductionAsRebound(EventCard currentEvent, int choice, int decisionMakerNo, Player p[]) 
	{
		GCWindow.outputStr("Now, you use this card to be rebound the deduction to decision maker.\n");
		p[decisionMakerNo].addPoint(currentEvent.getPoint(choice-1));
		return -1;
		
	}
	public int assignDescisionMaker(EventCard currentEvent, int currentPlayerNo, Player p[]) 
	{
		int choice=100;
		int assignedPlayer=100;
		
		GCWindow.outputStr("Now, you can assign one of the players as decision maker.\n");
		
		while (assignedPlayer<0 || assignedPlayer>=p.length||assignedPlayer==currentPlayerNo) {
			GCWindow.outputStr("Who do you want to be assigned? Please enter the player number: \n");
			for(int i=0; i<p.length; i++)
			{
				if(i!=currentPlayerNo)
					GCWindow.outputStr(p[i].getName()+ " , player no: " + i + "    \n");  
			}
			
			assignedPlayer=GCWindow.inputInt(0, p.length, "NULL");
			
			if(assignedPlayer==currentPlayerNo)
				GCWindow.outputStr("You cannot assigned yourself.\n");
		}
		
		currentEvent.displayChoiceDescription();
		
		choice=GCWindow.inputInt(Main.choiceMin, Main.choiceMax, p[assignedPlayer].getName() + ", please input your choice. Choice: \n");
		
		return choice;
	}
}

